<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    Inherits="PessoaBrowser" Title="Academia Triathlon ::: Gerenciamento de Pessoas" Codebehind="PessoaBrowser.aspx.cs" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="mainPlace" runat="Server">
    <ajaxToolkit:ToolkitScriptManager  ID="scmMain" runat="server">
    </ajaxToolkit:ToolkitScriptManager >
    <script type="text/javascript">
        <!-- #Include File="..\includes\default.js" -->
    </script>
    
    <asp:UpdatePanel ID="uppMain" runat="server">
        <contenttemplate>
            <div class="Title">
                Gerenciamento de Alunos
            </div>
            <br />
            Tipo de Pessoa:
            <asp:DropDownList ID="cbPessoaTipo" 
                runat="server" 
                SkinID="DropDownList" 
                CausesValidation="False" 
                AutoPostBack="True" 
                OnSelectedIndexChanged="cbPessoaTipo_SelectedIndexChanged">
                <asp:ListItem>Cliente Ativo</asp:ListItem>
                <asp:ListItem>Cliente Inativo</asp:ListItem>
                <asp:ListItem>Outros Funcion&#225;rios</asp:ListItem>
                <asp:ListItem>Professores</asp:ListItem>
                <asp:ListItem>Outros</asp:ListItem>
                <asp:ListItem>Visitante</asp:ListItem>
            </asp:DropDownList>&nbsp; Buscar:
            <asp:TextBox ID="txtSearch" runat="server" SkinID="TextBox"></asp:TextBox>
            <asp:LinkButton ID="btnSearch" runat="server" CausesValidation="False" OnClick="btnSearch_Click">Ok</asp:LinkButton><br />
            <br />
            <div>
                <asp:GridView ID="grdMain"  runat="Server" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" DataKeyNames="PessoaID" DataSourceID="dsPessoa" AllowPaging="True" AllowSorting="True" PageSize="5" ShowHeader="False" >
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <RowStyle BackColor="#EFF3FB" />
                    <EditRowStyle BackColor="#2461BF" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <AlternatingRowStyle BackColor="White" />
                    <Columns>
                        <asp:BoundField DataField="PessoaID" HeaderText="ID" InsertVisible="False"
                            ReadOnly="True" SortExpression="PessoaID" Visible="False" />
                        <asp:TemplateField HeaderText="Pessoa" SortExpression="Tipo">
                            <ItemTemplate>
                                <table>
                                    <tr>
                                        <td style="width: 137px">
                                            <asp:LinkButton ID="LinkButton1" runat="Server" OnClientClick="<%# &quot;javascript:OpenModalDialog('FotoEntry.aspx?key1=&quot; + Eval(&quot;PessoaID&quot;) + &quot;');&quot; %>" >Editar Foto</asp:LinkButton>
                                            <asp:Image ID="imgFoto" runat="server" Height="94px" ImageUrl='<%# "../Foto/" + Eval("FotoPath") %>' Width="104px" />&nbsp;</td>
                                        <td>
                                            <strong>
                                            Tipo:</strong>
                                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("Tipo") %>'></asp:Label><br />
                                            <strong>
                                            Nome:</strong>
                                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("Nome") %>'></asp:Label><br />
                                            <strong>
                                            Nascimento: </strong>
                                            <asp:Label ID="Label3" runat="server" Text='<%# Bind("Nascimento", "{0:d}") %>'></asp:Label><br />
                                            <br />
                                            <br />
                                            <asp:LinkButton ID="lnkEdit" runat="Server" OnClientClick="<%# &quot;javascript:OpenModalDialog('PessoaEntry.aspx?key1=&quot; + Eval(&quot;PessoaID&quot;) + &quot;');&quot; %>" >Editar</asp:LinkButton>
                                            |
                                            <asp:LinkButton ID="lnkDelete" runat="Server" CommandName="Delete"
                                                OnClientClick="javascript:return confirm('Deseja realmente excluir esta pessoa?')">Excluir</asp:LinkButton>
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Left" />
                            <HeaderStyle HorizontalAlign="Left" />
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        Nenhum registro encrontrado.
                    </EmptyDataTemplate>
                    <PagerSettings Position="TopAndBottom" />
                </asp:GridView>
                <br />
                <a href="javascript:OpenModalDialog('PessoaEntry.aspx');" >Novo</a>
                <asp:SqlDataSource ID="dsPessoa" runat="server" ConnectionString="<%$ ConnectionStrings:AcademiaConnectionString %>"
                    SelectCommand="SELECT [PessoaID], [Tipo], [CPF], [RG], [Nome], [Nascimento], [FotoPath] FROM VPessoa ORDER BY [Nome]"
                    DeleteCommand="DELETE FROM Pessoa WHERE [PessoaID] = @PessoaID" FilterExpression="Tipo = '{0}'">
                    <DeleteParameters>
                        <asp:Parameter Name="PessoaID" />
                    </DeleteParameters>
                    <FilterParameters>
                        <asp:ControlParameter ControlID="cbPessoaTipo" Name="Tipo" PropertyName="SelectedValue" />
                    </FilterParameters>
                </asp:SqlDataSource>
                </div>
        </contenttemplate>
    </asp:UpdatePanel>
    <br />
</asp:Content>